Hello and welcome to this video on javascript functions javascript functions are a block of code designed
to perform a certain task so the Turbo's group function is executed or called when some team invokes
it so to invoke it function means you're calling it to perform a task.
There are many built in functions in javascript.
You may have come across one before core alert that's responsible for a pop up boxes that comes up on
the browser.
You can also create your own functions A Germans group function is defined with the function key word
followed by the name then followed by per Empathy's you must enclose per hour is function names can
contain certain letters digits even underscores and their dollars size.
They also follow the same rules as the variables.
The parentheses may include parameter may include parameter names which are separated by commas so in
it parent this is you can add parameter 1 or parameters to be also known as arguments.
So the code that will be executed by the function is placed inside the curly braces or quarterly brackets
so they the caudell be executed by the function is placed inside the curly brackets function parameters.
Are their names listed in the function definition so where you define a function the actual parameters
are the names.
But when you actually give the function value being known as argument so function arguments are they
real values that I receive by the function when the function is invoked or caught inside a function
the arguments behaves as a local variable.
That means the variable is only available within the scope of function.
Function invocation or when you call it function means something happens that will make the function
to to perform a task.
For example when you click on a button on the website you are invoking a function.
Something happens in response to that click is called Click event but is driven by a function.
Functions also have a return statement so when the javascript function reaches a written statement the
function will stop executing the code stops so the function was invoked or called from his statement.
Ben Jealous group will return to execute the code after invoking this statement.
Functions that often compute Ireton value always return value back to the caller to were invoked the
function.
All right this is a sample function I have created that will add two numbers together and return value.
Functions are very useful in that you can define a function once and then reuse it as many times as
possible.
If you think about the alerts function that was the final ones and then you can use it any time you
want from within the browser.
All right so this is a function I have written to add two numbers together not to multiply two numbers
together.
So this is a keyword function and then giving it a name chord add numbers.
So it's all in between the parentheses are parameters so the only thing without asserting value inside
the premises is called parameters to a perimeter parameter number one and then parameter number two.
So I've also got a variable here called resort and the value only variable is number one times number
two.
So I change that to a plus.
Okay so so the value of this variable result will be a number one plus number to return here.
The written statement is used to return the result.
So when you actually pass actual values they're called argument.
So to call the function created a function here.
So to call the function.
So remember my side function now because this is a quote liberators So I'm calling the function outside
of the function.
Self CORELY is an alert and I've called it by its name.
His name is called numbers and I'm giving it to arguments.
So when you actually pass rule values poured arguments.
So because he specified here that it takes two parameters 1 and 2.
So now you are giving me real values which I known R's arguments have given me two arguments and there
they are.
So when I executed this alert function this alert function here it will show the results of the number
of the two values added together.
Right so this is an alert which is a function on his own built into javascript and then of course my
own function I've created called Ad numbers so functions are always identified by the parentheses.
This is my parentheses for my function and I've passed it to arguments.
So.
The Argue the values are real record arguments for where you expect something to be passed in the call
parameters as parameters 1 and parameter to the state.
I don't know why the vote would be so then known as paratrooper's.
But when you parse out all values they become arguments.
So this function here takes two arguments.
So let me run that and then you see the result.
They go 16 so it's giving me the result of 16 which is an added number one number two together and the
result is 16.
So this is why the alert from action as printed on the screen or displayed on the screen.
So in this video I gave you a brief introduction to.
Functions and how they are created and the benefits of having functions.
I hope the video has been useful.
If there are parts of the videos or if you don't understand any parts of it please message me.
I'll be more than happy to help.
Thank you so much for your time.